{#**
*
* 功能描述（添加蛋糕模板）
*
* @author suoya <jlusuoya@gmail.com>
* @version 1
*#}
{#include file="header.tpl" title="添加蛋糕" active="cake" #}
{#include file="define.tpl" scope=parent#}
<div class="content middle">
    <div class="ui breadcrumb">
        <a class="section" href="index.php">主页</a>
        <i class="right"></i>
        <a class="section" href="index.php?action=cake.showlist">产品管理</a>
        <i class="right"></i>
        <span class="active section">添加产品</span>
    </div>
    <div><p style='color: #ff8800'>主页展示规则：按“主页展示”、“新品”、“销量”、“最新修改”优先有选取8个非配件蛋糕，如果不足8个，随机重复到8个。如果想控制主页展示的商品，最好办法就是仅指定8个“主页展示”。</p></div>
    <form class="ui form" action="index.php?action=cake.add" method="POST" enctype="multipart/form-data" onsubmit="return submitForm(this);">
        <div class="inputDIV">
            <label class="title">产品编号：<span class="prompt">*</span></label>
            <div class="ui input" style="width: 400px;">
                <input type="text" class="input_text" name="no" >
                {#foreach $cake_type2 as $k => $v#}
                    <input name="type2" type="radio" value="{#$k#}"{#if $k==1#}checked{#/if#}><label>{#$v#}</label>
                {#/foreach#}
            </div>
        </div>
        <div class="inputDIV">
            <label class="title">产品名称：<span class="prompt">*</span></label>
            <div class="ui input">
                <input type="text" name="name" class="input_text" >
            </div>
        </div>
        <div class="inputDIV">
            <label class="title">所属类别：<span class="prompt">*</span></label>
            <select name='type'>{#foreach $cake_type as $k=>$v#}<option value='{#$k#}'>{#$v#}</option>{#/foreach#}</select>
        </div>
        <div class="inputDIV">
            <label class="title">保存方式：<span class="prompt">*</span></label>
            <select name='storage'>{#foreach $cake_storage as $v#}<option value='{#$v#}'>{#$v#}</option>{#/foreach#}</select>
        </div>
        <div class="inputDIV">
            <label class="title">产品介绍：<span class="prompt">*</span></label>
            <textarea name="introduce" style="width: 400px;" rows="5"></textarea>
        </div>
        <div class="inputDIV">
            <label class="title">折扣：</label>
            <span class="prompt"></span>
            <div class="ui input">
                <input type="text" name="discount" value="10" style="width: 40px;" class="input_text" >
            </div>
            <label class="tip">不打折为10折，小数最多一位。</label>
        </div>
        <div class="inputDIV">
            <label class="title">蛋糕图片：<span class="prompt">*</span></label>
            <div class="ui icon input">
                <input type="text" readonly="readonly" class="input_text">
                <input class="input_file_upload" type='file' name='mainimg' 
                       id="mainimg" accept='image/*' onchange="changeFileInput('mainimg');" />
            </div>
            <label class="tip">图片长宽比例为1:1，仅限jpg</label>
        </div>
        <div class="inputDIV">
            <label class="title">口味：</label>
            <span class="prompt"></span>
            <div class="ui input">
                <input type="text" name='taste' class="input_text" />
            </div>
        </div>
        <div class="inputDIV">
            <label class="title">适合人群：</label>
            <span class="prompt"></span>
            <div class="ui input">
                <input type="text" name='suits' class="input_text" />
            </div>
        </div>
        <div class="inputDIV">
            <label class="title">甜度：</label>
            <span class="prompt"></span>
            <div class="ui input">
                <select name='sweetness'>{#for $foo=1 to 5#}<option value='{#$foo#}'>{#$foo#}</option>{#/for#}</select>
            </div>
            <label class="tip">甜度1-5，5为最甜</label>
        </div>
        <div class="inputDIV">
            <label class="title">适合节日：</label>
            <span class="prompt"></span>
            <div class="ui input">
                <input type="text" name='holiday' class="input_text" />
            </div>
        </div>
        <div class="inputDIV">
            <label class="title">原材料：</label>
            <span class="prompt"></span>
            <textarea name="material" style="width: 400px;" rows="5"></textarea>
        </div>
        <div class="inputDIV">
            <label class="title">营养图片：<span class="prompt">*</span></label>
            <div class="ui icon input">
                <input type="text" readonly="readonly" class="input_text">
                <input class="input_file_upload" type='file' name='showimg' 
                       id="showimg" accept='image/*' onchange="changeFileInput('showimg');" />
            </div>
            <label class="tip">图片长宽比例为50:81，仅限jpg</label>
        </div>
        <div class="inputDIV">
            <label class="title" style="vertical-align: top;">营养成分：</label>
            <span class="prompt"></span>
            <div class="sub_inputDiv">
                <label>每100g含</label>
                <div class="inputDIV">
                    <label class='subTitle'>能量</label>
                    <input type="text" name='attr1' style='width: 60px;' class="input_text" />
                    <label class="subTitle">千焦</label>
                </div>
                <div class="inputDIV">
                    <label class='subTitle'>蛋白质</label>
                    <input type='text' name='attr2' style='width: 60px;' class="input_text" />
                    <label class="subTitle">克</label>
                </div>
                <div class="inputDIV">
                    <label class='subTitle'>脂肪</label>
                    <input type='text' name='attr3' style='width: 60px;' class="input_text" />
                    <label class="subTitle">克</label>
                </div>
                <div class="inputDIV">
                    <label class='subTitle'>碳水化合物</label>
                    <input type='text' name='attr4' style='width: 60px;' class="input_text" />
                    <label class="subTitle">克</label>
                </div>
                <div class="inputDIV">
                    <label class='subTitle'>钠</label>
                    <input type='text' name='attr5' style='width: 60px;' class="input_text" />
                    <label class="subTitle">毫克</label>
                </div>
            </div>
        </div>
        <div class="ui error message">
        </div>
        <div class="inputDIV">
            <input type="button" class="button align_right" value="返回" onclick="gotoUrl('index.php?action=cake.showlist');" />
            <input type="submit" class="button align_right" value="添加" />
        </div>
    </form>
</div>
<script>
    $('.ui.form').form({
        no: {
            identifier: 'no',
            rules: [
                {
                    type: 'empty',
                    prompt: '请输入产品编号'
                }
            ]
        },
        name: {
            identifier: 'name',
            rules: [
                {
                    type: 'empty',
                    prompt: '请输入产品名称'
                }
            ]
        },
        type: {
            identifier: 'type',
            rules: [
                {
                    type: 'empty',
                    prompt: '请输入所属类别'
                }
            ]
        },
        storage: {
            identifier: 'storage',
            rules: [
                {
                    type: 'empty',
                    prompt: '请输入保存方式'
                }
            ]
        },
        introduce: {
            identifier: 'introduce',
            rules: [
                {
                    type: 'empty',
                    prompt: '请输入产品介绍'
                }
            ]
        },
        mainimg: {
            identifier: 'mainimg',
            rules: [
                {
                    type: 'empty',
                    prompt: '请输入蛋糕图片'
                }
            ]
        },
        showimg: {
            identifier: 'showimg',
            rules: [
                {
                    type: 'empty',
                    prompt: '请输入营养图片'
                }
            ]
        }
    });

    function submitForm(oForm) {
        oForm.discount.value = oForm.discount.value / 10;
        return true;
    }

</script>
{#include file="footer.tpl"#}
